import React from 'react'
import { Button } from 'antd'
import propTypes from 'prop-types'
export default class Child extends React.Component{
    //获取上下文信息
    static contextTypes={
        msg:propTypes.string,
        change:propTypes.func
    }
    render(){
        let {msg,change}=this.context
        return <>
          <h3>------子组件-------</h3>
          <div>
              <p>来自上下文中的信息：》》 <span style={{color:'#0f0'}}>{msg}</span> </p>
              <Button type='primary' onClick={ev=>{change('子组件修改了的次数')}}>改变上下文中信息</Button>
          </div>
        </>
    }
}